package com.etc.dao;

import com.etc.entity.Recorddetails;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.List;

@Repository
public interface RecorddetailsDao extends JpaRepository<Recorddetails,Integer>,JpaSpecificationExecutor<Recorddetails>,Serializable {
    /*
    传入 电影场次的id 得到已选座位的集合
     */
    @Query(value="SELECT rd.seatid FROM Recorddetails rd Where rd.rid IN (SELECT rid FROM Record r WHERE cid=?1 and rid not in (SELECT u.rid from unpaid u where (UNIX_TIMESTAMP(NOW())- UNIX_TIMESTAMP(u.placetime))>10*60) ) ",nativeQuery = true)
    List<String> findSeatByCid(Integer cid);
}